package cn.doitedu.day07

import org.apache.spark.sql.{DataFrame, SparkSession}

//DSL 领域特定语言
object T24_DSLDemo2 {

  def main(args: Array[String]): Unit = {

    val spark = SparkSession.builder().appName(this.getClass.getSimpleName)
      .master("local[*]")
      .getOrCreate()

    //创建DataFrame
    val df = spark.read
      .option("header", "true")
      .option("delimiter", "|")
      .csv("data/flow2.txt")

    import spark.implicits._

    //不用注册视图，直接调用dataFrame上的方法
    val df2: DataFrame = df.select($"uid", $"flow")

    //调用过滤
    val df3: DataFrame = df2.where($"flow" >= 50)

    df3.printSchema()

    df3.show()
  }
}
